package com.member.shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.member.common.enums.OrderDeleteEnum;
import com.member.common.utils.DateUtils;
import com.member.shop.domain.SysBizMemberGrade;
import com.member.shop.domain.SysBizShopCategory;
import com.member.shop.mapper.SysBizMemberGradeMapper;
import com.member.shop.service.ISysBizMemberGradeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

/**
 * 会员等级Service业务层处理
 *
 * @author lixinchen
 * @date 2024-12-29
 */
@Service
public class SysBizMemberGradeServiceImpl extends ServiceImpl<SysBizMemberGradeMapper, SysBizMemberGrade> implements ISysBizMemberGradeService {
    @Resource
    private SysBizMemberGradeMapper sysBizMemberGradeMapper;

    /**
     * 查询会员等级
     *
     * @param id 会员等级主键
     * @return 会员等级
     */
    @Override
    public SysBizMemberGrade selectSysBizMemberGradeById(Long id) {
        return sysBizMemberGradeMapper.selectById(id);
    }

    /**
     * 查询会员等级列表
     *
     * @param sysBizMemberGrade 会员等级
     * @return 会员等级
     */
    @Override
    public List<SysBizMemberGrade> selectSysBizMemberGradeList(LambdaQueryWrapper<SysBizMemberGrade> queryWrapper) {
        return sysBizMemberGradeMapper.selectList(queryWrapper);
    }

    /**
     * 新增会员等级
     *
     * @param sysBizMemberGrade 会员等级
     * @return 结果
     */
    @Override
    public int insertSysBizMemberGrade(SysBizMemberGrade sysBizMemberGrade) {
        sysBizMemberGrade.setCreateTime(DateUtils.getNowDate());
        return sysBizMemberGradeMapper.insert(sysBizMemberGrade);
    }

    /**
     * 修改会员等级
     *
     * @param sysBizMemberGrade 会员等级
     * @return 结果
     */
    @Override
    public int updateSysBizMemberGrade(SysBizMemberGrade sysBizMemberGrade) {
        sysBizMemberGrade.setUpdateTime(DateUtils.getNowDate());
        return sysBizMemberGradeMapper.updateById(sysBizMemberGrade);
    }

    /**
     * 批量删除会员等级
     *
     * @param ids 需要删除的会员等级主键
     * @return 结果
     */
    @Override
    public int deleteSysBizMemberGradeByIds(Long[] ids) {
        return sysBizMemberGradeMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除会员等级信息
     *
     * @param id 会员等级主键
     * @return 结果
     */
    @Override
    public int deleteSysBizMemberGradeById(Long id) {
        SysBizMemberGrade sysBizMemberGrade = new SysBizMemberGrade();
        sysBizMemberGrade.setId(id);
        sysBizMemberGrade.setDeleted((long) OrderDeleteEnum.DELETE.getKey());
        return sysBizMemberGradeMapper.updateById(sysBizMemberGrade);
    }
}
